package common

import (
	"context"
	"device-admin/config/redis"
	"device-admin/internal/define"
	"strconv"
	"time"
)

// GetBattery 实时电量
func GetBattery(robotID string) int {
	ctx, cancel := context.WithTimeout(context.Background(), time.Second*3)
	defer cancel()
	battery, _ := redis.NewDB().HGet(
		ctx,
		define.RedisRobotRTInfo+robotID,
		"battry",
	).Result()
	batteryInt, _ := strconv.Atoi(battery)
	return batteryInt
}
